//
//  LHMultipleSelectAlertCell.m
//  Loohoo
//
//  Created by 陈镇 on 2025/4/17.
//

#import "LHMultipleSelectAlertCell.h"


@interface LHMultipleSelectAlertCell ()

@property(nonatomic,strong) QMUILabel *title;
@property(nonatomic,strong) QMUIButton *selectIocn;

@end
@implementation LHMultipleSelectAlertCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self.contentView addSubview:self.title];
        [self.contentView addSubview:self.selectIocn];
        
        
    }
    return self;
}

-(QMUILabel *)title{
    if (!_title) {
        
        _title = [[QMUILabel alloc] init];
    }
    return _title;
}
-(QMUIButton *)selectIocn{
    if (!_selectIocn) {
        _selectIocn = [[QMUIButton alloc] init];
        _selectIocn.userInteractionEnabled = NO;
    }
    return _selectIocn;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    [self createFrame];
}
-(void)createFrame{
    
    _title.frame = CGRectMake(20, 0, self.contentView.width - 40, self.height);
    _selectIocn.frame = CGRectMake(self.contentView.width - 12 - self.height, 0, self.height, self.height);

    
}


-(void)setSelect_select_Image:(NSString *)select_select_Image{
    _select_select_Image = select_select_Image;
    
    
    [_selectIocn setImage:[[UIImage imageNamed:select_select_Image] qmui_imageWithTintColor:self.cellSelectTextColor] forState:UIControlStateSelected];
}

-(void)setSelect_default_Image:(NSString *)select_default_Image{
    _select_default_Image = select_default_Image;
    [_selectIocn setImage:[UIImage imageNamed:select_default_Image] forState:UIControlStateNormal];

}


-(void)setModel:(LHMultipleSelectAlertViewCellModel *)model{
    
    _model = model;

    

    _selectIocn.selected = model.isSelect;
    
    if (model.attributedTitle) {
        _title.attributedText = model.attributedTitle;
        if (model.isSelect) {
            _title.attributedText = model.selectAttributedTitle;
        }
        
    }else{
        _title.text = model.title;
        
        if (model.isSelect) {
            _title.textColor = self.cellSelectTextColor;
            _title.font = self.cellSelectTextFont;
        }else{
            _title.textColor = self.cellTextColor;
            _title.font = self.cellTextFont;
        }
    }
    
    _selectIocn.hidden = !_ableSelect;
}

@end
